package com.ewanghuiju.app.ui.resale.activity;

import android.view.Gravity;

import com.ewanghuiju.app.R;
import com.ewanghuiju.app.base.BaseActivity;
import com.ewanghuiju.app.base.contract.resale.ResalePublishShopContract;
import com.ewanghuiju.app.presenter.resale.ResalePublishShopPresenter;
import com.ewanghuiju.app.widget.popupwindow.CustomBasePopup;
import com.gyf.immersionbar.ImmersionBar;

/**
 * @author sj  qq:751943509
 * @class 转售确认订单
 * @time 2020/2/19
 */
public class ResalePublishShopActivity extends BaseActivity<ResalePublishShopPresenter> implements ResalePublishShopContract.View {

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_resale_publish_shop;
    }

    @Override
    protected void initEventAndData() {
    }

//    @Override
//    public void showPay(BaseResponse baseResponse) {
//        LoadingDialogUtils.dismissDialog_ios();
//        StyleableToast.makeText(mContext, "兑换成功", Toast.LENGTH_SHORT, R.style.mytoast).show();
//        //通知更新   刷新用户信息
//        RxBus.getDefault().post(new SendEvent("", Constants.TYPE_GET_USERINFO));
//        //刷新商品信息
//        RxBus.getDefault().post(new SendEvent("", Constants.TYPE_GET_WATER_SHOP_INFO));
//        //支付完成
//        new StartActivityUtil(mContext, WaterOrderListActivity.class)
//                .startActivity(false);
//        super.onBackPressedSupport();
//        slideRightIn();
//
//    }
//
//    @Override
//    public void showPayError(int code, String msg) {
//        //实付失败
//    }
//
//    @Override
//    public void isbindPwd() {
//        //绑定成功
////        PswKeyboardPopup pswKeyboardPopup = new PswKeyboardPopup(mContext);
////        pswKeyboardPopup.setPopupGravity(Gravity.BOTTOM);
////        pswKeyboardPopup.setOnFinishInput(new OnPasswordInputFinish() {
////            @Override
////            public void inputFinish(String password) {
////                pswKeyboardPopup.dismiss();
////                if (!StringUtil.isInteger(password)) {
////                    StyleableToast.makeText(mContext, "密码输入格式错误", Toast.LENGTH_SHORT, R.style.mytoast).show();
////                    pswKeyboardPopup.dismiss();
////                    return;
////                }
////                String orderRemarks = etOrderRemarks.getText().toString();
////                String md5Pwd = MD5Util.getMD5(MD5Util.getMD5(password));
////                LoadingDialogUtils.show(mContext);
////                mPresenter.nowPay(waterShopResponBean.getId() + "", "1",
////                        addressListResponBean.getId() + "", md5Pwd, TextUtils.isEmpty(orderRemarks) ? "" : orderRemarks);
////            }
////        });
////
////        //弹框执行动画
////        float fromX = 0;
////        float fromY = 1f;
////        float toX = 0;
////        float toY = 0;
////        showAnimation = createTranslateAnimation(fromX, toX, fromY, toY);
////        dismissAnimation = createTranslateAnimation(toX, fromX, toY, fromY);
////
////        pswKeyboardPopup.setShowAnimation(showAnimation);
////        pswKeyboardPopup.setDismissAnimation(dismissAnimation);
////
////        pswKeyboardPopup.showPopupWindow();
//    }
//
//    private CustomBasePopup customBasePopup;
//
//    @Override
//    public void nobindPwd() {
//        //未绑定支付密码
//        if (customBasePopup != null) {
//            customBasePopup.showPopupWindow();
//            return;
//        }
//        customBasePopup = new CustomBasePopup(mContext, "前往设置支付密码？", "", "",
//                new CustomBasePopup.PopupWindowCallback() {
//                    @Override
//                    public void sureClickCallback() {
//                        new StartActivityUtil(mContext, ChangeBodyWithCodeActivity.class).putExtra(Constants.SETTING_TYPE, 2)
//                                .startActivity(true);
//                    }
//
//                    @Override
//                    public void cancelClickCallback() {
//
//                    }
//                });
//        customBasePopup.setPopupGravity(Gravity.CENTER);
//        customBasePopup.showPopupWindow();
//    }
//
//    @OnClick({R.id.tv_order_topay, R.id.layout_address_main})
//    public void doClick(View view) {
//        if (AntiShake.check(view.getId())) {    //判断是否多次点击
//            return;
//        }
//        switch (view.getId()) {
//            case R.id.tv_order_topay:
//                //立即支付
//                if (waterShopResponBean == null) {
//                    StyleableToast.makeText(mContext, "商品信息出错", Toast.LENGTH_SHORT, R.style.mytoast).show();
//                    return;
//                }
//                break;
//            case R.id.layout_address_main:
//                new StartActivityUtil(mContext, ShopAddressListActivity.class).putExtra(Constants.TO_ADDRESS_LIST_TYPE, 2)
//                        .startActivity(true);
//                break;
//            default:
//                break;
//        }
//    }

    @Override
    public void onBackPressedSupport() {

        CustomBasePopup customBasePopup = new CustomBasePopup(mContext, "确认要放弃付款吗？", "继续支付", "暂时放弃",
                new CustomBasePopup.PopupWindowCallback() {
                    @Override
                    public void sureClickCallback() {
                    }

                    @Override
                    public void cancelClickCallback() {
                        ResalePublishShopActivity.super.onBackPressedSupport();
                    }
                });
        customBasePopup.setPopupGravity(Gravity.CENTER);
        customBasePopup.showPopupWindow();
    }

    @Override
    protected int getTitleIntText() {
        return R.string.publish_shop_title;
    }

    @Override
    protected void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).titleBar(mToolbar)
                .statusBarDarkFont(true)
                .init();
    }
}
